import axios from "axios"
import type { InternalAxiosRequestConfig, AxiosResponse } from "axios"
import { useStore } from "@/piniaStore"
const $piniaStore = useStore()

const service = axios.create({
    // baseURL: "http://localhost:3000"
    baseURL: "http://39.105.109.147:3000"
})

// 请求拦截器
service.interceptors.request.use((config: InternalAxiosRequestConfig) => {
    $piniaStore.changeShowLoading(true)
    return config
})
// 响应拦截器
service.interceptors.response.use((res: AxiosResponse) => {
    $piniaStore.changeShowLoading(false)
    return res
})

export default service